import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc'

dayjs.extend(utc)
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss'

/**
 * 格式化utc类型时间
 * @param utcString
 * @param format
 * @returns
 */
export function formatUtcString(
  utcString: string,
  format: string = DATE_TIME_FORMAT
) {
  return dayjs.utc(utcString).format(format)
}

/**
 * 格式化时间戳类型时间
 * @param timestamp
 * @param format
 * @returns
 */
export function formatTimeStamp(
  timestamp: string,
  format: string = DATE_TIME_FORMAT
) {
  return dayjs(timestamp).format(format)
}
